//清空前后空格
export function trim(val) {
  return val.trim();
}

//时间格式化
export function formatDate() {
  let date = new Date();

  let year = date.getFullYear();
  let mon = date.getMonth() + 1;
  if (mon < 10) {
    mon = "0" + mon;
  }
  let day = date.getDate();
  if (day < 10) {
    day = "0" + day;
  }
  let week = date.getDay();
  switch (week) {
    case 0:
      week = "星期日";
      break;
    case 1:
      week = "星期一";
      break;
    case 2:
      week = "星期二";
      break;
    case 3:
      week = "星期三";
      break;
    case 4:
      week = "星期四";
      break;
    case 5:
      week = "星期五";
      break;
    default:
      week = "星期六";
      break;
  }
  let h = date.getHours();
  if (h < 10) {
    h = "0" + h;
  }
  let m = date.getMinutes();
  if (m < 10) {
    m = "0" + m;
  }
  let s = date.getSeconds();
  if (s < 10) {
    s = "0" + s;
  }
  return (
    year + "-" + mon + "-" + day + " " + week + " " + h + ":" + m + ":" + s
  );
}
